package com.societyGames.interceptExercises
{
public class NegateExpression implements INumberExpression
{
  private var _right:INumberExpression;

  public function NegateExpression(xml:XML)
  {
    if (xml.children().length() != 1)
    {
      throw new ArgumentError("NegateExpression requires one child.");
    }
    this._right = Parser.parse(xml.children()[0]);
  }

  public function toString():String
  {
    return "negate(" + Object(this._right).toString() + ")";
  }

  //INumberExpression-->
  public function evaluate():Number
  {
    return -this._right.evaluate();
  }

  //<--INumberExpression
}
}